package com.blue.alipay.enums;

public enum ErrorEnum {
    SUCCESS(0, "成功"),
    SYSTEM_ERROR(1, "系统异常"),
    PARAM_NULL(2, "参数是null"),
    PARAM_ERROR(3, "参数校验失败"),
    SIGN_INVALID(4, "签名无效"),
    USER_ID_INVALID(5, "无效的用户ID"),
    USER_ID_NOT_MATCH(6, "用户Id不匹配"),
    USER_NOT_EXIST(7, "用户不存在"),
    PAY_CHANNEL_INVALID(8, "无效的支付渠道"),
    PAY_REPEAT(9, "已经支付过"),
    PAY_ORDER_NOT_EXIST(10, "支付订单不存在"),
    PAY_CHANNEL_BALANCE_INSUFFICIENT(11, "支付金额不足"),
    CALL_PAY_CHANNEL_EEROR(12, "调用三方渠道接口异常"), // 请求逻辑错误
    CALL_PAY_CHANNEL_FAIL(13, "调用三方渠道接口失败"), // 出现系统级参数错误，请检测Post给API的数据是否合法
    CALL_PAY_CHANNEL_BIZ_FAIL(14, "调用三方渠道接口业务失败"), // 有些情况需要做些额外的处理来提示用户
    ACCOUNT_FREEZN(15, "账户已经被冻结"),
    TRADE_NOT_EXIST(16, "交易不存在"),
    TRADE_EXIST_CANNOT_INERT(17, "该交易已经存在,不允许本次交易插入"),
    CARD_BALANCE_INSUFFICIENT(18, "卡余额不足"),
    CALLBACK_BUSINESS_FAIL(19, "回调业务线失败"),
    REFUND_MONEY_NEGATIVE(20, "退款金额是负数"),
    REFUND_MONEY_NIMEITY(21, "累计退款金额超过了支付金额，不能退款"),
    ORDER_ID_INVALID(22, "订单ID无效"),
    CHANNEL_NOTIFY_FAIL(23, "支付渠道异步回调返回失败"),
    BILL_DOWNLOAD_FAIL(24, "对账单下载失败"),
    CHANNEL_SERVICE_NOT_FOUND(25, "找不到支付渠道服务类");

    private int code;
    private String desc;

    ErrorEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return "[" + code + "]" + desc;
    }

    public static String getValueByCode(int code) {
        for (ErrorEnum errorEnum : values()) {
            if (code == errorEnum.code) {
                return errorEnum.getDesc();
            }
        }
        return null;
    }
}
